/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.lzyzsd.circleprogress.utils.properties.model;

import com.github.lzyzsd.circleprogress.Utils;
import com.github.lzyzsd.circleprogress.utils.properties.CircleProgressResPropertyHolder;
import com.github.lzyzsd.circleprogress.utils.properties.IInterface.CommonPropertyModel;
import ohos.agp.components.AttrSet;
import ohos.agp.utils.Color;
import ohos.app.Context;

public class CircleProgressModel extends CommonPropertyModel {
    private Color finishedColor = new Color(Color.rgb(66,145,241));
    private Color unfinishedColor = new Color(Color.rgb(204,204,204));
    private Color textColor = new Color(Color.rgb(255,255,255));
    private int textSize ;
    private String prefixText = "";
    private String suffixText = "%";
    private int progress = 0;
    private int max = 100;

    public CircleProgressModel(Context context) {
        textSize = Utils.sp2px(context.getResourceManager(), 18);
    }

    public Color getFinishedColor() {
        return finishedColor;
    }

    public Color getUnfinishedColor() {
        return unfinishedColor;
    }

    public Color getTextColor() {
        return textColor;
    }

    public int getTextSize() {
        return textSize;
    }

    public String getPrefixText() {
        return prefixText;
    }

    public String getSuffixText() {
        return suffixText;
    }

    public int getProgress() {
        return progress;
    }

    public int getMax() {
        return max;
    }

    public void setFinishedColor(Color finishedColor) {
        this.finishedColor = finishedColor;
    }

    public void setUnfinishedColor(Color unfinishedColor) {
        this.unfinishedColor = unfinishedColor;
    }

    public void setTextColor(Color textColor) {
        this.textColor = textColor;
    }

    public void setTextSize(int textSize) {
        this.textSize = textSize;
    }

    public void setPrefixText(String prefixText) {
        this.prefixText = prefixText;
    }

    public void setSuffixText(String suffixText) {
        this.suffixText = suffixText;
    }

    public void setProgress(int progress) {
        this.progress = progress;
    }

    public void setMax(int max) {
        this.max = max;
    }

    public static class Builder {
        private CircleProgressModel circleProgressModel;

        public Builder(Context context, AttrSet attrSet) {
            circleProgressModel = new CircleProgressResPropertyHolder(context, attrSet).obtainProperty();
        }

        public Builder setFinishedColor(Color finishedColor) {
            circleProgressModel.finishedColor = finishedColor;
            return this;
        }

        public Builder setUnfinishedColor(Color unfinishedColor) {
            circleProgressModel.unfinishedColor = unfinishedColor;
            return this;
        }

        public Builder setTextColor(Color textColor) {
            circleProgressModel.textColor = textColor;
            return this;
        }

        public Builder setTextSize(int textSize) {
            circleProgressModel.textSize = textSize;
            return this;
        }

        public Builder setPrefixText(String prefixText) {
            circleProgressModel.prefixText = prefixText;
            return this;
        }

        public Builder setSuffixText(String suffixText) {
            circleProgressModel.suffixText = suffixText;
            return this;
        }

        public Builder setProgress(int progress) {
            circleProgressModel.progress = progress;
            return this;
        }

        public Builder setMax(int max) {
            circleProgressModel.max = max;
            return this;
        }

        public CircleProgressModel build() {
            return circleProgressModel;
        }
    }
}
